import React, { useContext } from 'react';
import Schema from '../../store/schema';
import {
    FormItem,
    Editable,
    Input,
    Select,
    Radio,
    DatePicker,
    ArrayItems,
    FormButtonGroup,
    Submit,
    Space,
} from '@formily/antd'
import { createForm } from '@formily/core'
import { FormProvider, createSchemaField } from '@formily/react'
import style from './index.less'


const SchemaField = createSchemaField({
    components: {
        FormItem,
        Editable,
        DatePicker,
        Space,
        Radio,
        Input,
        Select,
        ArrayItems,
    },
})

const form = createForm()
const SchemaCustom = () => {
    const schema = useContext(Schema)
    console.log(schema)
    return (
        <div className={style.form_list}>
            <FormProvider form={form}>
                <SchemaField schema={schema} />
                <FormButtonGroup>
                    <Submit onSubmit={console.log}>提交</Submit>
                </FormButtonGroup>
            </FormProvider>
        </div>
    )

}

export default SchemaCustom